From 33c6edba078d3432d5fb231887d1060de7ef6c3b Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 29 Oct 2014 21:59:06 -0400 Subject: [PATCH] fail -> panic --- src/cargo/core/shell.rs | 2 +- src/cargo/core/source.rs | 6 +++--- src/cargo/sources/git/source.rs | 2 +- src/cargo/util/sha256.rs | 2 +- tests/support/mod.rs | 10 +++++----- tests/test_cargo_bench.rs | 2 +- tests/test_cargo_compile.rs | 4 ++-- tests/test_cargo_run.rs | 2 +- tests/test_cargo_test.rs | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index f1c71f47e..b5570f0dd 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -169,7 +169,7 @@ impl<'a> Terminal> for Shell<'a> { } fn unwrap(self) -> Box { - fail!("Can't unwrap a Shell"); + panic!("Can't unwrap a Shell"); } fn get_ref<'b>(&'b self) -> &'b Box { diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index cde5523d8..3d9a717f1 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -118,14 +118,14 @@ impl SourceId { .with_precise(Some("locked".to_string())) } "path" => SourceId::for_path(&Path::new(url.slice_from(5))).unwrap(), - _ => fail!("Unsupported serialized SourceId") + _ => panic!("Unsupported serialized SourceId") } } pub fn to_url(&self) -> String { match *self.inner { SourceIdInner { kind: PathKind, .. } => { - fail!("Path sources are not included in the lockfile, \ + panic!("Path sources are not included in the lockfile, \ so this is unimplemented") }, SourceIdInner { @@ -192,7 +192,7 @@ impl SourceId { PathKind => { let path = match self.inner.url.to_file_path() { Ok(p) => p, - Err(()) => fail!("path sources cannot be remote"), + Err(()) => panic!("path sources cannot be remote"), }; box PathSource::new(&path, self) as Box }, diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 870bcaa3e..7febd6080 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -30,7 +30,7 @@ impl<'a, 'b> GitSource<'a, 'b> { let reference = match source_id.git_reference() { Some(reference) => reference, - None => fail!("Not a git source; id={}", source_id), + None => panic!("Not a git source; id={}", source_id), }; let remote = GitRemote::new(source_id.get_url()); diff --git a/src/cargo/util/sha256.rs b/src/cargo/util/sha256.rs index 294bdbaba..19a24a8dc 100644 --- a/src/cargo/util/sha256.rs +++ b/src/cargo/util/sha256.rs @@ -109,7 +109,7 @@ mod imp { macro_rules! call( ($e:expr) => ({ if $e == 0 { - fail!("failed {}: {}", stringify!($e), os::last_os_error()) + panic!("failed {}: {}", stringify!($e), os::last_os_error()) } }) ) diff --git a/tests/support/mod.rs b/tests/support/mod.rs index cb8f16443..544e9800d 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -144,7 +144,7 @@ impl ProjectBuilder { // TODO: return something different than a ProjectBuilder pub fn build(&self) -> &ProjectBuilder { match self.build_with_result() { - Err(e) => fail!(e), + Err(e) => panic!(e), _ => return self } } @@ -227,7 +227,7 @@ pub fn cargo_dir() -> Path { os::getenv("CARGO_BIN_PATH").map(Path::new) .or_else(|| os::self_exe_path()) .unwrap_or_else(|| { - fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test") + panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test") }) } @@ -327,7 +327,7 @@ impl Execs { (None, Some(e)) => { Some(format!("{:3} - |{}|\n +\n", i, e)) }, - (None, None) => fail!("Cannot get here") + (None, None) => panic!("Cannot get here") } }); @@ -450,7 +450,7 @@ impl ResultTest for Result { fn assert(self) -> T { match self { Ok(val) => val, - Err(err) => fail!("Result was error: {}", err) + Err(err) => panic!("Result was error: {}", err) } } } @@ -459,7 +459,7 @@ impl ResultTest for Option { fn assert(self) -> T { match self { Some(val) => val, - None => fail!("Option was None") + None => panic!("Option was None") } } } diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index a661d795e..e6efc9e62 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -401,7 +401,7 @@ test!(dont_run_examples { .file("src/lib.rs", r#" "#) .file("examples/dont-run-me-i-will-fail.rs", r#" - fn main() { fail!("Examples should not be run by 'cargo test'"); } + fn main() { panic!("Examples should not be run by 'cargo test'"); } "#); assert_that(p.cargo_process("bench"), execs().with_status(0)); diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index f8b777813..9b8d74ed0 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -628,7 +628,7 @@ test!(custom_build_failure { name = "foo" "#) .file("src/foo.rs", r#" - fn main() { fail!("nope") } + fn main() { panic!("nope") } "#); assert_that(build.cargo_process("build"), execs().with_status(0)); @@ -691,7 +691,7 @@ test!(custom_second_build_failure { name = "bar" "#) .file("src/bar.rs", r#" - fn main() { fail!("nope") } + fn main() { panic!("nope") } "#); assert_that(build2.cargo_process("build"), execs().with_status(0)); diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index 97fc5e31c..4f8270ba0 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -260,7 +260,7 @@ test!(release_works { authors = [] "#) .file("src/main.rs", r#" - fn main() { if !cfg!(ndebug) { fail!() } } + fn main() { if !cfg!(ndebug) { panic!() } } "#); assert_that(p.cargo_process("run").arg("--release"), diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 901499c44..c4cb668bd 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -390,7 +390,7 @@ test!(dont_run_examples { .file("src/lib.rs", r#" "#) .file("examples/dont-run-me-i-will-fail.rs", r#" - fn main() { fail!("Examples should not be run by 'cargo test'"); } + fn main() { panic!("Examples should not be run by 'cargo test'"); } "#); assert_that(p.cargo_process("test"), execs().with_status(0)); @@ -855,7 +855,7 @@ test!(test_no_run { "#) .file("src/lib.rs", " #[test] - fn foo() { fail!() } + fn foo() { panic!() } "); assert_that(p.cargo_process("test").arg("--no-run"), -- 2.30.2